home *** CD-ROM | disk | FTP | other *** search
/ AppleScript - The Beta Release / AppleScript - The Beta Release.iso / Development Tools / Interfaces / PInterfaces / Components.p < prev    next >
Text File  |  1992-10-02  |  8KB  |  248 lines

  1.  
  2. {
  3. Created: Wednesday, August 14, 1991 at 12:11 PM
  4.  Components.p
  5.  Pascal Interface to the Macintosh Libraries
  6.  
  7.  Copyright Apple Computer, Inc. 1990 - 1991
  8.  All rights reserved
  9.  
  10. }
  11.  
  12.  
  13. {$IFC UNDEFINED UsingIncludes}
  14. {$SETC UsingIncludes := 0}
  15. {$ENDC}
  16.  
  17. {$IFC NOT UsingIncludes}
  18.  UNIT Components;
  19.  INTERFACE
  20. {$ENDC}
  21.  
  22. {$IFC UNDEFINED UsingComponents}
  23. {$SETC UsingComponents := 1}
  24.  
  25. {$I+}
  26. {$SETC ComponentsIncludes := UsingIncludes}
  27. {$SETC UsingIncludes := 1}
  28. {$IFC UNDEFINED UsingTypes}
  29. {$I $$Shell(PInterfaces)Types.p}
  30. {$ENDC}
  31. {$SETC UsingIncludes := ComponentsIncludes}
  32.  
  33. CONST
  34. gestaltComponentMgr = 'cpnt';
  35.  
  36. kAnyComponentType =            0;
  37. kAnyComponentSubType =         0;
  38. kAnyComponentManufacturer =    0;
  39. kAnyComponentFlagsMask =    0;
  40.  
  41. cmpWantsRegisterMessage = $80000000;
  42.  
  43.  
  44. TYPE
  45. ComponentDescription = RECORD
  46.  componentType: OSType;                                { A unique 4-byte code indentifying the command set }
  47.  componentSubType: OSType;                            { Particular flavor of this instance }
  48.  componentManufacturer: OSType;                        { Vendor indentification }
  49.  componentFlags: LONGINT;                            { 8 each for Component,Type,SubType,Manuf/revision }
  50.  componentFlagsMask: LONGINT;                        { Mask for specifying which flags to consider in search, zero during registration }
  51.  END;
  52.  
  53. ResourceSpec = RECORD
  54.  resType: OSType;                                    { 4-byte code  }
  55.  resId: INTEGER;                                    {    }
  56.  END;
  57.  
  58. ComponentResourcePtr = ^ComponentResource;
  59. ComponentResourceHandle = ^ComponentResourcePtr;
  60. ComponentResource = RECORD
  61.  cd: ComponentDescription;                            { Registration parameters }
  62.  component: ResourceSpec;                            { resource where Component code is found }
  63.  componentName: ResourceSpec;                        { name string resource }
  64.  componentInfo: ResourceSpec;                        { info string resource }
  65.  componentIcon: ResourceSpec;                        { icon resource }
  66.  END;
  67.  
  68. { Structure received by Component:  }
  69. ComponentParameters = PACKED RECORD
  70.  flags: CHAR;                                        { call modifiers: sync/async, deferred, immed, etc }
  71.  paramSize: CHAR;                                    { size in bytes of actual parameters passed to this call }
  72.  what: INTEGER;                                        { routine selector, negative for Component management calls }
  73.  params: ARRAY [0..0] OF LONGINT;                    { actual parameters for the indicated routine }
  74.  END;
  75.  
  76.  
  77. Component = ^ComponentRecord;
  78. ComponentRecord = RECORD
  79.  data: ARRAY [0..0] OF LONGINT;
  80.  END;
  81.  
  82. ComponentInstance = ^ComponentInstanceRecord;
  83. ComponentInstanceRecord = RECORD
  84.  data: ARRAY [0..0] OF LONGINT;
  85.  END;
  86.  
  87.  
  88.  
  89. ComponentResult = LONGINT;
  90.  
  91. ComponentRoutine = LONGINT;
  92.  
  93. ComponentFunction = LONGINT;
  94.  
  95.  
  96.  
  97. { *******************************************************
  98. *                                                     *
  99. *              APPLICATION LEVEL CALLS                *
  100. *                                                     *
  101. *******************************************************
  102. * Component Database Add, Delete, and Query Routines 
  103. *******************************************************
  104.  }
  105. FUNCTION RegisterComponent(cd: ComponentDescription;componentEntryPoint: ComponentRoutine;
  106.  global: INTEGER;componentName: Handle;componentInfo: Handle;componentIcon: Handle): Component;
  107.  INLINE $7001,$A82A;
  108. FUNCTION RegisterComponentResource(tr: ComponentResourceHandle;global: INTEGER): Component;
  109.  INLINE $7012,$A82A;
  110. FUNCTION UnregisterComponent(aComponent: Component): OSErr;
  111.  INLINE $7002,$A82A;
  112.  
  113. FUNCTION FindNextComponent(aComponent: Component;looking: ComponentDescription): Component;
  114.  INLINE $7004,$A82A;
  115. FUNCTION CountComponents(looking: ComponentDescription): LONGINT;
  116.  INLINE $7003,$A82A;
  117.  
  118. FUNCTION GetComponentInfo(aComponent: Component;cd: ComponentDescription;
  119.  componentName: Handle;componentInfo: Handle;componentIcon: Handle): OSErr;
  120.  INLINE $7005,$A82A;
  121. FUNCTION GetComponentListModSeed: LONGINT;
  122.  INLINE $7006,$A82A;
  123.  
  124.  
  125. { *******************************************************
  126. * Component Instance Allocation and dispatch routines 
  127. *******************************************************
  128.  }
  129. FUNCTION OpenComponent(aComponent: Component): ComponentInstance;
  130.  INLINE $7007,$A82A;
  131. FUNCTION CloseComponent(aComponentInstance: ComponentInstance): OSErr;
  132.  INLINE $7008,$A82A;
  133.  
  134. FUNCTION GetComponentInstanceError(aComponentInstance: ComponentInstance): OSErr;
  135.  INLINE $700A,$A82A;
  136.  
  137.  
  138. {  direct calls to the Components  }
  139. FUNCTION ComponentFunctionImplemented(ci: ComponentInstance;ftnNumber: INTEGER): LONGINT;
  140.  INLINE $2F3C,$2,$FFFD,$7000,$A82A;
  141. FUNCTION GetComponentVersion(ci: ComponentInstance): LONGINT;
  142.  INLINE $2F3C,$0,$FFFC,$7000,$A82A;
  143.  
  144. CONST
  145.  
  146. {****************************************************
  147. *                                                    *
  148. *               CALLS MADE BY Components             *
  149. *                                                    *
  150. ******************************************************
  151. ******************************************************
  152. * Required Component routines
  153. ******************************************************}
  154.  
  155. kComponentOpenSelect = -1;                            { ComponentInstance for this open }
  156. kComponentCloseSelect = -2;                            { ComponentInstance for this close }
  157. kComponentCanDoSelect = -3;                            { selector # being queried }
  158. kComponentVersionSelect = -4;                        { no params }
  159. kComponentRegisterSelect = -5;                        { no params }
  160. kComponentTargetSelect = -6;                        { ComponentInstance for top of call chain }
  161.  
  162.  
  163. { *******************************************************
  164. * Component Management routines
  165. *******************************************************
  166.  }
  167. PROCEDURE SetComponentInstanceError(aComponentInstance: ComponentInstance;
  168.  theError: OSErr);
  169.  INLINE $700B,$A82A;
  170.  
  171. FUNCTION GetComponentRefcon(aComponent: Component): LONGINT;
  172.  INLINE $7010,$A82A;
  173. PROCEDURE SetComponentRefcon(aComponent: Component;theRefcon: LONGINT);
  174.  INLINE $7011,$A82A;
  175.  
  176. FUNCTION OpenComponentResFile(aComponent: Component): INTEGER;
  177.  INLINE $7015,$A82A;
  178. FUNCTION CloseComponentResFile(refnum: INTEGER): OSErr;
  179.  INLINE $7018,$A82A;
  180.  
  181.  
  182. { *******************************************************
  183. * Component Instance Management routines
  184. *******************************************************
  185.  }
  186. FUNCTION GetComponentInstanceStorage(aComponentInstance: ComponentInstance): Handle;
  187.  INLINE $700C,$A82A;
  188. PROCEDURE SetComponentInstanceStorage(aComponentInstance: ComponentInstance;
  189.  theStorage: Handle);
  190.  INLINE $700D,$A82A;
  191.  
  192. FUNCTION GetComponentInstanceA5(aComponentInstance: ComponentInstance): LONGINT;
  193.  INLINE $700E,$A82A;
  194. PROCEDURE SetComponentInstanceA5(aComponentInstance: ComponentInstance;
  195.  theA5: LONGINT);
  196.  INLINE $700F,$A82A;
  197.  
  198. FUNCTION CountComponentInstances(aComponent: Component): LONGINT;
  199.  INLINE $7013,$A82A;
  200.  
  201. {  useful helper routines for convenient method dispatching  }
  202. FUNCTION CallComponentFunction(params: ComponentParameters;func: ComponentFunction): LONGINT;
  203.  INLINE $70FF,$A82A;
  204. FUNCTION CallComponentFunctionWithStorage(storage: Handle;params: ComponentParameters;
  205.  func: ComponentFunction): LONGINT;
  206.  INLINE $70FF,$A82A;
  207. FUNCTION DelegateComponentCall(originalParams: ComponentParameters;
  208.  ci: ComponentInstance): LONGINT;
  209.  INLINE $7024,$A82A;
  210.  
  211. CONST
  212.  
  213. { Set Default Component flags }
  214. defaultComponentIdentical = 0;
  215. defaultComponentAnyFlags = 1;
  216. defaultComponentAnyManufacturer = 2;
  217. defaultComponentAnySubType = 4;
  218. defaultComponentAnyFlagsAnyManufacturer = defaultComponentAnyFlags+defaultComponentAnyManufacturer;
  219. defaultComponentAnyFlagsAnyManufacturerAnySubType = defaultComponentAnyFlags+defaultComponentAnyManufacturer+defaultComponentAnySubType;
  220.  
  221. FUNCTION SetDefaultComponent(aComponent: Component;flags: INTEGER): OSErr;
  222.  INLINE $701E,$A82A;
  223. FUNCTION  OpenDefaultComponent(componentType: OSType; componentSubType: OSType ) : ComponentInstance;
  224.  INLINE $7021,$A82A;
  225. FUNCTION CaptureComponent(capturedComponent: Component;capturingComponent: Component): Component;
  226.  INLINE $701C,$A82A;
  227. FUNCTION UncaptureComponent(aComponent: Component): OSErr;
  228.  INLINE $701D,$A82A;
  229.  
  230.  
  231. CONST
  232.  
  233. { errors from component manager & components }
  234. invalidComponentID = -3000;
  235. validInstancesExist = -3001;
  236. componentNotCaptured = -3002;
  237. componentDontRegister = -3003;
  238.  
  239. badComponentInstance = $80008001;
  240. badComponentSelector = $80008002;
  241.  
  242. {$ENDC} { UsingComponents }
  243.  
  244. {$IFC NOT UsingIncludes}
  245.  END.
  246. {$ENDC}
  247.  
  248.